<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>故障诊断工具</title>
    <link rel="stylesheet" href="../css/main.min.css">
    <link rel="stylesheet" href="../css/datetimepicker.css">
    <script src="../js/moment-with-locales.min.js"></script>
    <script>
        moment.locale('zh-cn');
    </script>
    <script src="../js/main.min.js"></script>
    <script src="../js/datetimepicker.js"></script>
    <script src="../js/datetimepicker.templates.js"></script>
    <script src="../base/core.js"></script>
</head>
<body ng-app="myApp" ng-controller="diagnosisController">
<div class="container-fluid">
    <div class="row">
        <div class="col-md-3">
            <div class="dropdown" uib-dropdown is-open="status.isopen">
                <a uib-dropdown-toggle class="dropdown-toggle" id="dropdown" role="button" data-toggle="dropdown" data-target=".dropdown" href="#">
                    <div class="input-group" style="width:20em">
                        <input type="text" id="date" name="date" style="width:10em" class="form-control input input-auto" size="14" data-ng-value="dt | date:'yyyy年MM月dd日'">
                        <div style="width:20em" uib-timepicker ng-click="timeClick($event)" ng-model="dt" ng-change="onTimeSet()" show-seconds="true" show-spinners="false" hour-step="1" minute-step="1" show-meridian="false" ></div>
                        <!--<input type="text" id="time" name="time" style="width:50%" class="form-control" data-ng-value="dt | date:'hh:mm:ss ms'" ng-click="timeClick($event)" ng-change="timeChanged($event)" data-ng-model-options="{updateOn:'default blur',debounce:{default:5000,blur:0}}">-->
                        <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
                    </div>
                </a>
                <ul uib-dropdown-menu class="dropdown-menu" role="menu" aria-labelledby="dLabel">
                    <datetimepicker   data-ng-model="dt" data-datetimepicker-config="{minuteStep:1,minView:'day'}"
                                     data-on-set-time="onTimeSet()"></datetimepicker>
                </ul>
            </div>
        </div>
        <div class="col-md-1">
            <button type="button" class="btn btn-default" ng-click="isCollapsed = !isCollapsed">显示/隐藏测点数据</button>
        </div>
        <div class="col-md-1">
            <div class="input-group" style="width:20em">
                <input type="text" id="timestamp" name="timestamp" style="width:15em" class="form-control input input-auto" size="14" ng-model="t_timestamp">
                <span class="input-group-btn">
                    <button class="btn btn-default" type="button" ng-click="toTimestamp()">转到时间戳</button>
                </span>
            </div>
        </div>
    </div>
    <div class="row">
        <div uib-collapse="isCollapsed">
            <div class="btn-group" ng-if="faultMatched!=null && faultMatched.length>0">
                <label ng-repeat="f in faultMatched | filter:{isMatched:true}" ng-model="f.checked" class="btn" ng-class="{true : 'btn-danger',false : 'btn-danger' }[f.isMatched]" uib-btn-checkbox>
                    {{f.faultName}}
                </label>
            </div>
            <table class="table table-responsive table-bordered">
                <thead><tr>
                    <th>ID</th><th>信号类型</th><th>测量值</th>
                </tr></thead>
                <tbody>
                <tr ng-repeat="signal in signals | filter:inCheckList track by $index">
                    <td>
                        {{$index+1}}
                    </td>
                    <td>
                        {{signal.portName}}
                    </td>
                    <td>
                        {{signal.value | startX:2}}
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <button type="button" class="btn btn-default" ng-click="isCollapsed2 = !isCollapsed2">显示/隐藏匹配结果</button>
        <div class="btn-group">
            <label class="btn btn-primary" ng-model="showUnknown" uib-btn-radio="false">只显示完全匹配的故障</label>
            <label class="btn btn-primary" ng-model="showUnknown" uib-btn-radio="true">显示不完全匹配的故障</label>
        </div>
        <div uib-collapse="isCollapsed2">
            <table class="table table-responsive table-bordered">
                <thead><tr>
                    <th>故障名称</th><th>报告查看</th><th>诊断解释</th>
                </tr></thead>
                <tbody>
                <tr ng-repeat="fault in faultMatched | filter:withUnknown" ng-class="{true : 'bg-danger',false : 'bg-gray' }[fault.isMatched]">
                    <td>{{fault.faultName}}</td>
                    <td>
                        <a ng-show="fault.isMatched" ng-click="showFaultReport(fault.id)">诊断报告</a>
                        <a ng-show="!fault.isMatched" ng-click="jumpToHuman(fault.id)">补充条件</a>
                    </td>
                    <td>
                        <a ng-click="showFaultTree(fault.id)">诊断解释</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <button type="button" class="btn btn-default" ng-click="isCollapsed3 = !isCollapsed3">显示/隐藏补充信息</button>
        <button type="button" class="btn btn-default" ng-click="diagnoiseAgain()">重新诊断</button>
        <div uib-collapse="isCollapsed3">
            <table class="table table-responsive table-bordered">
                <thead><tr>
                    <th>ID</th><th>所属故障</th><th>特征类型</th><th>测点位置</th><th>取值</th><th>操作</th>
                </tr></thead>
                <tbody>
                <tr ng-repeat="signal in manmalSignals track by $index">
                    <td>{{$index+1}}</td>
                    <td>{{signal.faultName}}</td>
                    <td>{{signal.type=="manual"?("(人工)"+signal.description):signal.featureType}}</td>
                    <td>{{signal.type=="manual"?"-":signal.component.name}}</td>
                    <td>
                        <div class="btn-group" ng-if='signal.type=="manual"'>
                            <label class="btn btn-success" ng-model="signal.value" uib-btn-radio="'on'">是</label>
                            <label class="btn btn-success" ng-model="signal.value" uib-btn-radio="'off'">否</label>
                            <label class="btn btn-success" ng-model="signal.value" uib-btn-radio="'unknown'">不确定</label>
                        </div>
                        <textarea ng-if='signal.type!="manual"' ng-model="signal.value" placeholder="请输入一段JSON取值" ></textarea>
                    </td>
                    <td>
                        <a ng-click="deleteManualSignal(signal.id)">删除该项</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>


<script src="faultDiagnosis2.js"></script>
</body>
</html>